import Vue from 'vue'
import Print from 'vue-print-nb'
Vue.use(Print);
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import i18n from './lang'
import '@/icons' // icon
// mixin 全局混入 对象
import checkPermission from './mixin/checkPermission';
Vue.mixin(checkPermission)
import '@/permission' // permission control
// 生成一个对象 导出的所有自定义指令对象 
import * as directives from '@/directives'
// console.log(directives);
// 变量对象 for in 
// 对象 keys 所有的属性转换为数组
// console.log(Object.keys(directives));
Object.keys(directives).forEach(key => {
    // console.log(key); 
    // console.log(directives[key]);
    // 循环注册所有的自定义指令
    Vue.directive(key, directives[key])
});
import * as filters from '@/filters' // 引入工具类
// 注册全局的过滤器
Object.keys(filters).forEach(key => {
        // 注册过滤器
        Vue.filter(key, filters[key])
    })
    /**
     * If you don't want to use mock-server
     * you want to use MockJs for mock api
     * you can execute: mockXHR()
     *
     * Currently MockJs will be used in the production environment,
     * please remove it before going online ! ! !
     */
    // if (process.env.NODE_ENV === 'production') {
    //   const { mockXHR } = require('../mock')
    //   mockXHR()
    // }

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
    // 如果想要中文版 element-ui，按如下方式声明
    // Vue.use(ElementUI)
// 根据i18n动态读取语言内容
// 设置element为当前的语言
Vue.use(ElementUI, {
    // 根据lang/index.js中的locale 找对应的语言包
    i18n: (key, value) => i18n.t(key, value)
  })

import components from '@/components'
Vue.use(components)
Vue.config.productionTip = false

new Vue({
    el: '#app',
    router,
    store,
    i18n,
    render: h => h(App)
})